﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace newTestNHibernate
{
    public partial class DToKhaiMD
    {
        //public string Ten_DV
        //{
        //    get
        //    {
        //        return GetTenDV(MaDV);
        //    }
        //}

        //public string Ten_DVKT
        //{
        //    get
        //    {
        //        return GetTenDV(Ma_DVKT);
        //    }
        //}

        //public string Ten_HQ
        //{
        //    get
        //    {
        //        return GetTenHQ(MaHQ);
        //    }
        //}

        //public string Ten_CK
        //{
        //    get
        //    {
        //        return GetTenCK(Ma_CK);
        //    }
        //}

        //private string GetTenDV(string maDV)
        //{
        //    using (var context = new SLXNKEntities())
        //    {
        //        var donVi = context.SDONVIs.Where(dv => dv.Ma_DV == maDV).First();

        //        return donVi.Ten_DV;
        //    }
        //}

        //private string GetTenHQ(string maHQ)
        //{
        //    using (var context = new SLXNKEntities())
        //    {
        //        var haiQuan = context.SHAIQUANs.Where(hq => hq.Ma_HQ == maHQ).First();

        //        return haiQuan.Ten_HQ;
        //    }
        //}

        //private string GetTenCK(string maCK)
        //{
        //    using (var context = new SLXNKEntities())
        //    {
        //        var cuaKhau = context.SCUAKHAUs.Where(ck => ck.Ma_CK == maCK).First();

        //        return cuaKhau.Ten_CK;
        //    }            
        //}

        //public enum AgentStatus
        //{
        //    DaiLyLamThuTucHQ = 1, UyThac = 2, NguoiKhai = 3, NguoiChiuTrachNhiemNopThue = 4, MaMID = 5
        //}

        //public enum MessageFuntion
        //{
        //    Huy = 1, Sua = 5, KhaiBao = 8, ChuaXuLy = 12, HoiTrangThai = 13, DeNghi = 16, KhongChapNhan = 27,
        //    CapSoTiepNhan = 29, CapSoToKhai = 30, DuyetLuongChungTu = 31, ThongBaoThongQuan = 32, ThongBaoThucXuat = 33, ThongBaoGiamSat = 34
        //}

        //public enum MessageType
        //{
        //    HopDong = 315, HoaDonThuongMai = 380, AirwayBill = 740,
        //    ImportableList = 501, ExportableList = 502,
        //    EPZImportDeclaration = 933, EPZExportDelcaration = 934, ImportFromLocal = 937, ExportToDomestic = 938
        //}

        //public enum CommodityType
        //{
        //    NguyenPhuLieu = 1,
        //    SanPham = 2,
        //    ThietBi = 3,
        //    HangMau = 4,
        //    PhePham = 5,
        //    TieuDung = 6,
        //    LoaiKhac = 7
        //}

        //public string ToXML()
        //{
        //    string referenceID = System.Guid.NewGuid().ToString();
        //    string loaiTK;
        //    if (MaLH.Substring(0).ToUpper() == "N")
        //        loaiTK = ((int)MessageType.EPZImportDeclaration).ToString();
        //    else
        //        loaiTK = ((int)MessageType.EPZExportDelcaration).ToString();


        //    string result = "";
        //    result = "<?xml version='1.0' encoding='UTF-8' ?><Envelope><Header><procedureType>2</procedureType>" +
        //    "<Reference><version>3.00</version><messageId>" + System.Guid.NewGuid().ToString() + "</messageId></Reference>";
        //    result += "<From>" +
        //                "<name>" + Ten_DVKT + "</name>" +
        //                "<identity>" + Ma_DVKT + "</identity>" +
        //              "</From>" +
        //              "<To>" +
        //                "<name>" + Ten_HQ + "</name>" +
        //                "<identity>" + MaHQ + "</identity>" +
        //              "</To>";
        //    result += "<Subject>" +
        //                "<type>" + loaiTK + "</type>" +
        //                "<function>" + (int)MessageFuntion.KhaiBao + "</function>" +
        //                "<reference>" + referenceID + "</reference>" +
        //              "</Subject></Header>";
        //    //body
        //    result += "<Body><Content>" +
        //                "<Declaration>" +
        //                    "<issuer>" + loaiTK + "</issuer>" +
        //                    "<reference>" + referenceID + "</reference>" +
        //                    "<issue>" + Ngay_KB.ToString() + "</issue>" +
        //                    "<function>" + (int)MessageFuntion.KhaiBao + "</function>" +
        //                    "<status>" + "1" + "</status>" + //Status khong dung, luon dat la 1
        //                    "<declarationOffice>" + MaHQ + "</declarationOffice>";
        //    result += "<goodsItem>" + SoHang + "</goodsItem><loadingList>0</loadingList>";//So luong chung tu phu luc dinh kem luon la 0 voi Intel
        //    result += "<totalGrossMass>" + Tr_Luong + "</totalGrossMass>";
        //    result += "<natureOfTransaction>" + MaLH + "</natureOfTransaction>";
        //    result += "<paymentMethod>" + Ma_PTTT + "</paymentMethod>";
        //    result += "<Agent>" +
        //                "<name>" + Ten_DVKT + "</name>" +
        //                "<identity>" + Ma_DVKT + "</identity>" +
        //                "<status>" + (int)AgentStatus.DaiLyLamThuTucHQ + "</status>" + //Lay o dau
        //              "</Agent>";
        //    result += "<Agent>" +
        //                "<name>" + Ten_DVKT + "</name>" +
        //                "<identity>" + Ma_DVKT + "</identity>" +
        //                "<status>" + (int)AgentStatus.NguoiKhai + "</status>" + //Lay o dau
        //              "</Agent>";
        //    result += "<CurrencyExchange>" +
        //                "<currencyType>" + Ma_NT + "</currencyType>" +
        //                "<rate>" + TyGia_VND + "</rate>" +
        //              "</CurrencyExchange>";
        //    result += "<DeclarationPackaging><quantity>" + SoHang + "</quantity></DeclarationPackaging>";
        //    //Khong noi dung ve cac chung tu kem theo trong dtokhaimd
        //    result += "<AdditionalDocument>" +
        //                "<issue>" + Ngay_HD.ToString() + "</issue>" +
        //                "<reference>" + So_HD + "</reference>" +
        //                "<type>" + (int)MessageType.HopDong + "</type>" +
        //                "<name>Contract</name>" +
        //              "</AdditionalDocument>";
        //    result += "<AdditionalDocument>" +
        //                "<issue>" + Ngay_VanDon.ToString() + "</issue>" +
        //                "<reference>" + Van_Don + "</reference>" +
        //                "<type>" + (int)MessageType.AirwayBill + "</type>" +
        //                "<name>Air waybill</name>" +
        //              "</AdditionalDocument>";
        //    result += "<Invoice>" +
        //                "<issue>" + Ngay_HDTM.ToString() + "</issue>" +
        //                "<reference>" + So_HDTM + "</reference>" +
        //                "<type>" + (int)MessageType.HoaDonThuongMai + "</type>" +
        //              "</Invoice>";
        //    //Khong co noi dung ve dai ly trong bang dtokhaimd
        //    result += "<Importer>" +
        //                "<name>" + Ten_DV + "</name>" +
        //                "<identity>" + MaDV + "</identity>" +
        //              "</Importer>";
        //    result += "<RepresentativePerson>" +
        //                "<contactFunction>x</contactFunction><name>x</name>" +
        //              "</RepresentativePerson>";
        //    result += "<GoodsShipment>";
        //    result += "<exportationCountry>" + Nuoc_XK + "</exportationCountry>";
        //    result += "<Consignor><name>" + DV_DT + "</name></Consignor>";
        //    result += "<Consignee>" +
        //                "<name>" + Ten_DVKT + "</name>" +
        //                "<identity>" + Ma_DVKT + "</identity>" +
        //              "</Consignee>";
        //    //Noi dung trong line o dau
        //    result += "<DeliveryDestination><line>HCM</line></DeliveryDestination>";
        //    result += "<EntryCustomsOffice><name>" + Ten_CK + "</name><code>" + Ma_CK + "</code></EntryCustomsOffice>";
        //    result += "<Exporter><name>" + DV_DT + "</name></Exporter>";
        //    result += "<TradeTerm><condition>" + Ma_GH + "</condition></TradeTerm>";
        //    foreach (DHangMD Hang in DHangMDs)
        //    {
        //        string loaiHang;
        //        if (Hang.Ma_Phu.Substring(0) == "N")
        //            loaiHang = ((int)CommodityType.NguyenPhuLieu).ToString();
        //        else if (Hang.Ma_Phu.Substring(0) == "S")
        //            loaiHang = ((int)CommodityType.SanPham).ToString();
        //        else if (Hang.Ma_Phu.Substring(0) == "T")
        //            loaiHang = ((int)CommodityType.ThietBi).ToString();
        //        else if (Hang.Ma_Phu.Substring(0) == "C")
        //            loaiHang = ((int)CommodityType.TieuDung).ToString();
        //        else //if (Hang.Ma_Phu.Substring(0) == "U")
        //            loaiHang = ((int)CommodityType.LoaiKhac).ToString();
        //        result += "<CustomsGoodsItem>" +
        //                    "<customsValue>" + Hang.TriGia_KB + "</customsValue>" +
        //                    "<sequence>" + Hang.STTHang + "</sequence>" +
        //                    "<statisticalValue>" + Hang.TriGia_TT + "</statisticalValue>" +
        //                    "<unitPrice>" + Hang.DGia_KB + "</unitPrice>" +
        //                    "<Origin>" +
        //                        "<originCountry>" + Hang.Nuoc_XX + "</originCountry>" +
        //                    "</Origin>" +
        //                    "<Commodity>" +
        //                        "<description>" + Hang.Ten_Hang + "</description>" +
        //                        "<identification>" + Hang.Ma_Phu + "</identification>" +
        //                        "<tariffClassification>" + Hang.Ma_HangKB + "</tariffClassification>" +
        //                        "<type>" + loaiHang + "</type>" +
        //                    "</Commodity>" +
        //                    "<GoodsMeasure>" +
        //                        "<quantity>" + Hang.Luong + "</quantity>" +
        //                        "<measureUnit>" + Hang.Ma_DVT + "</measureUnit>" +
        //                    "</GoodsMeasure>" +
        //                  "</CustomsGoodsItem>";
        //    }
        //    result += "</GoodsShipment></Declaration></Content></Body></Envelope>";

        //    return result;
        //}
    }
}
